home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 1
/
Cream of the Crop 1.iso
/
PROGRAM
/
CHEKBOOK.ARJ
/
081592C.CPP
next >
Wrap
C/C++ Source or Header
|
1992-08-26
|
3KB
|
68 lines
#include<stdlib.h>
#include<ctype.h>
#include<stdio.h> /* header files */
main ()
{
int checks = 0, var = 0; /* definitions and initializations */
float deposit, s_charge, balance, check;
char transac, C, D, S;
s_charge = 0;
printf ("C H E C K B O O K P R O G R A M F O R U N I X & C\n");
printf ("\n\nWhat is your opening balance? --> ");/* ask user for balance */
scanf ("%f", &balance);
printf ("\nYour opening balance is $%7.2f\n", balance);
printf ("\t\t Here are the choices: \n\n");
printf ("C: Checks\n"); /* menu choices */
printf ("D: Deposits\n");
printf ("S: Stop Transactions\n");
loop: printf ("Your choice is-> "); /* first goto loop */
fflush(stdin);
transac = toupper (fgetc(stdin)); /* get a character from user and make */
/* it uppercase */
switch (transac) /* switch statement */
{
case 'C': printf ("What is the check money amount? \n");
scanf ("%f", &check); /* ask for check amount */
checks += 1; /* total the # of checks */
balance = balance - check; /* make a new balance */
if (balance < 500 ) { /* flag service charge */
var = 1;
}
goto loop; /* goto: return to menu */
loop2: if (var == 1) /* second goto loop to end transactions */
{ /* and report the balance minus the */
balance -= .25 * checks; /* service charge */
s_charge = .25 * checks; /* compute the service charge */
printf ("Balance is $%7.2f & it has $%3.2f service charge that was taken off.\n", balance, s_charge);
break; /* break */
}
printf ("Balance is $%7.2f & there was no service charges.", balance);
break;
case 'D': printf ("What is the deposit money amount? \n");
scanf ("%f", &deposit); /* ask for deposit amount */
balance = balance + deposit; /* make a new balance */
goto loop; /* goto */
case 'S': goto loop2; /* ends transactions and goes */
/* to compute the totals */
default: printf ("Option is illegal. Start again:\n");/* account for error */
goto loop; /* goto menu */
} /* switch */
} /* main */